# coding: utf8
import itertools

def cartesian_product(a, b):
    return set([(x, y) for x in a for y in b])

# множество всех подмножеств
def powerset(s):
    ps = set([frozenset()])
    if s:
        t = s.copy()
        u = set([t.pop()])
        ps = powerset(t)
        ps |= set([p | u for p in ps])
    return ps

def powerset2(s):
    return itertools.chain.from_iterable(itertools.combinations(s, r)
                                         for r in range(len(s) + 1))

def odd_naturals():
    start = 1
    while True:
        yield start
        start += 2

def even_integers():
    i = 0
    while True:
        yield i
        if i == 0:
            i += 2
        elif i > 0:
            i *= -1
        else:
            i *= -1
            i += 2
